import 'package:seedfour/generated/json/base/json_convert_content.dart';
import 'package:seedfour/app/models/file_search_list_entity.dart';

FileSearchListEntity $FileSearchListEntityFromJson(Map<String, dynamic> json) {
  final FileSearchListEntity fileSearchListEntity = FileSearchListEntity();
  final int? total = jsonConvert.convert<int>(json['total']);
  if (total != null) {
    fileSearchListEntity.total = total;
  }
  final List<FileSearchData>? data = (json['data'] as List<dynamic>?)
      ?.map(
          (e) => jsonConvert.convert<FileSearchData>(e) as FileSearchData)
      .toList();
  if (data != null) {
    fileSearchListEntity.data = data;
  }
  return fileSearchListEntity;
}

Map<String, dynamic> $FileSearchListEntityToJson(FileSearchListEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['total'] = entity.total;
  data['data'] = entity.data?.map((v) => v.toJson()).toList();
  return data;
}

extension FileSearchListEntityExtension on FileSearchListEntity {
  FileSearchListEntity copyWith({
    int? total,
    List<FileSearchData>? data,
  }) {
    return FileSearchListEntity()
      ..total = total ?? this.total
      ..data = data ?? this.data;
  }
}

FileSearchData $FileSearchDataFromJson(Map<String, dynamic> json) {
  final FileSearchData fileSearchData = FileSearchData();
  final String? caseId = jsonConvert.convert<String>(json['caseId']);
  if (caseId != null) {
    fileSearchData.caseId = caseId;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    fileSearchData.name = name;
  }
  final String? takername = jsonConvert.convert<String>(json['takername']);
  if (takername != null) {
    fileSearchData.takername = takername;
  }
  final int? fileId = jsonConvert.convert<int>(json['fileId']);
  if (fileId != null) {
    fileSearchData.fileId = fileId;
  }
  final String? remark = jsonConvert.convert<String>(json['remark']);
  if (remark != null) {
    fileSearchData.remark = remark;
  }
  final String? fileName = jsonConvert.convert<String>(json['fileName']);
  if (fileName != null) {
    fileSearchData.fileName = fileName;
  }
  final int? deliveryType = jsonConvert.convert<int>(json['deliveryType']);
  if (deliveryType != null) {
    fileSearchData.deliveryType = deliveryType;
  }
  final int? createdAt = jsonConvert.convert<int>(json['createdAt']);
  if (createdAt != null) {
    fileSearchData.createdAt = createdAt;
  }
  final int? applyType = jsonConvert.convert<int>(json['applyType']);
  if (applyType != null) {
    fileSearchData.applyType = applyType;
  }
  final String? applyId = jsonConvert.convert<String>(json['applyId']);
  if (applyId != null) {
    fileSearchData.applyId = applyId;
  }
  return fileSearchData;
}

Map<String, dynamic> $FileSearchDataToJson(FileSearchData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['caseId'] = entity.caseId;
  data['name'] = entity.name;
  data['takername'] = entity.takername;
  data['fileId'] = entity.fileId;
  data['remark'] = entity.remark;
  data['fileName'] = entity.fileName;
  data['deliveryType'] = entity.deliveryType;
  data['createdAt'] = entity.createdAt;
  data['applyType'] = entity.applyType;
  data['applyId'] = entity.applyId;
  return data;
}

extension FileSearchDataExtension on FileSearchData {
  FileSearchData copyWith({
    String? caseId,
    String? name,
    String? takername,
    int? fileId,
    String? remark,
    String? fileName,
    int? deliveryType,
    int? createdAt,
    int? applyType,
    String? applyId,
  }) {
    return FileSearchData()
      ..caseId = caseId ?? this.caseId
      ..name = name ?? this.name
      ..takername = takername ?? this.takername
      ..fileId = fileId ?? this.fileId
      ..remark = remark ?? this.remark
      ..fileName = fileName ?? this.fileName
      ..deliveryType = deliveryType ?? this.deliveryType
      ..createdAt = createdAt ?? this.createdAt
      ..applyType = applyType ?? this.applyType
      ..applyId = applyId ?? this.applyId;
  }
}